package com.xiaoyu.crypto;

import java.awt.RenderingHints.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class Crypto {
	private static final String TAG = "Crypto";

	public Crypto() {

	}

	public static SecretKey generateKey() {
		SecretKey sKey = null;
		try {
			KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
			sKey = keyGenerator.generateKey();
		} catch (NoSuchAlgorithmException e) {
			System.out.println(TAG + ":No such algorithm exception");
		}
		return sKey;
	}

	public static KeyPair generateKeyPair() {
		KeyPair keyPair = null;
		try {
			KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
			kpg.initialize(1024);
			keyPair = kpg.genKeyPair();
		} catch (Exception e) {
			e.printStackTrace();
		}

		return keyPair;

	}

}
